<?php if(!empty($student_all_profiles)) :?>
	<div class="accord">
	  <?php foreach($student_all_profiles as $v): ?>
			
			<?php
				$profile = isset($v['profile']) && $v['profile'] ? $v['profile'] : FALSE;
				$attendance = isset($v['attendance']) && $v['attendance'] ? $v['attendance'] : FALSE;
			?>	

			<h4>SY <?php echo $profile->sy_from.' - '.$profile->sy_to; echo $profile->desc!=''?' ( '.$profile->desc.' )':''; ?></h4>

			<div>
				<?if($attendance):?>
					
					<div class="table-responsive">
						
						<?if(isset($attendance)):?>
								<table class="table table-bordered table-stripped table-compressed">
									<tr class="info">
										<td>Term Attendance</td>
											<?foreach($gp as $k=>$v):?>
												<td  style="font-weight:bold;"><?=strtoupper($v->gp_code);?></td>
											<?endforeach;?>
										<td>Total</td>
									</tr>
										<tr>
											<td>Total No. of Days</td>
											<?$tot_no_day = 0;?>
											<?foreach($attendance as $grading_p_id => $v):?>
												<?if(isset($v->generate)):?>
													<td>No available attendance as of the moment.</td>
												<?else:?>

													<?$tot_no_day += $v->no_of_days;?>
													<td><span class="badge badge-<?=_att_badge('tot',$v->no_of_days)?>"><?=floatval($v->no_of_days);?></span></td>

												<?endif;?>
												
											<?endforeach?>
											<td><div class="badge badge-<?=_att_badge('tot',$tot_no_day)?>"><?=$tot_no_day;?></div></td>
										</tr>

										<tr>
											<td>Absent</td>
											<?$tot_absent = 0;?>
											<?foreach($attendance as $grading_p_id => $v):?>
												<?if(!isset($v->generate)):?>

													<?$tot_absent += $v->absent;?>
													<td><span class="badge badge-<?=_att_badge('ab',$v->absent)?>"><?=floatval($v->absent);?></span></td>

												<?endif;?>
											<?endforeach?>
											<td><div class="badge badge-<?=_att_badge('ab',$tot_absent)?>"><?=$tot_absent;?></div></td>
										</tr>

										<tr>
											<td>Present</td>
											<?$tot_present = 0;?>
											<?foreach($attendance as $grading_p_id => $v):?>
											<?if(!isset($v->generate)):?>

												<?$tot_present += $v->present;?>
												<td><span class="badge badge-<?=_att_badge('pre',$v->present)?>"><?=floatval($v->present);?></span></td>

											<?endif;?>
											<?endforeach?>
											<td><div class="badge badge-<?=_att_badge('pre',$tot_present)?>"><?=$tot_present;?></div></td>
										</tr>

										<tr>
											<td>Tardy</td>
											<?$tot_tardy = 0;?>
											<?foreach($attendance as $grading_p_id => $v):?>
											<?if(!isset($v->generate)):?>

												<?$tot_tardy += $v->tardy;?>
												<td><span class="badge badge-<?=_att_badge('tar',$v->tardy)?>"><?=floatval($v->tardy);?></span></td>

											<?endif;?>
											<?endforeach?>

											<td><div class="badge badge-<?=_att_badge('tar',$tot_tardy)?>"><?=$tot_tardy;?></div></td>
										</tr>
								</table>
						<?endif;?>

					</div>

				<?else:?>
					<div class="alert alert-warning">No attendance created yet.</div>
				<?endif;?>
			</div>

		<?php endforeach; ?>
	</div>
<?php endif; ?>